package cn.aku.d2_collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class work_day14 {
    public static void main(String[] args) {
        w2();
    }

    public static void w3() {
        /*
            3.现有指向ArrayList对象的集合引用list，
            该集合中有元素["java","php","android"],
            要求使用Iterator遍历该集合，并删除集合中的java

         */
        List<String> list=new ArrayList<>();
        list.add("java");
        list.add("php");
        list.add("android");
        Iterator<String> it=list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        list.remove("java");//list.remove(0)
        System.out.println(list);


    }

    public static void w1(){
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++) {
            list.add(i);//0-9
        }
        List<Integer> subList = list.subList(4, 9);//[4,9)
        for (int i = 0; i < subList.size(); i++) {
            subList.set(i, subList.get(i) * 10);
        }
        System.out.println(list);
    }

    public static void w2(){

        List<String> list = new ArrayList<>();

        //向集合list中依次插入 "one"、"two"、"three"、 "four"、"five"、"six"
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("six");
        System.out.println(list);
        //list.set(3,"one")---返回值为3下标的元素
        list.set(4,"four");
        System.out.println(list);



    }

}
